<!DOCTYPE html>




<html class="theme-next gemini" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="源码,BiliBili,UWP,C#," />





  <link rel="alternate" href="/atom.xml" title="cyf 小博客" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico?v=5.1.2" />






<meta name="description" content="BiliBili UWP 源码阅读  1  -  视频播放控制  因为需要将Vt.Client嵌入进一个稳定播放的环境，于是就开始阅读UWP版bilibili的源码。原作者代码托管：这里。">
<meta property="og:type" content="article">
<meta property="og:title" content="BiliBili UWP源码阅读 1 - 视频播放控制">
<meta property="og:url" content="http://cyf-my.gitee.io/2020/07/19/uwpbili-src-read-1/index.html">
<meta property="og:site_name" content="cyf 小博客">
<meta property="og:description" content="BiliBili UWP 源码阅读  1  -  视频播放控制  因为需要将Vt.Client嵌入进一个稳定播放的环境，于是就开始阅读UWP版bilibili的源码。原作者代码托管：这里。">
<meta property="article:published_time" content="2020-07-19T09:20:40.000Z">
<meta property="article:modified_time" content="2020-07-19T16:02:57.031Z">
<meta property="article:author" content="cyf">
<meta property="article:tag" content="源码">
<meta property="article:tag" content="BiliBili">
<meta property="article:tag" content="UWP">
<meta property="article:tag" content="C#">
<meta name="twitter:card" content="summary">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":true,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: false,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://cyf-my.gitee.io/2020/07/19/uwpbili-src-read-1/"/>





  <title>BiliBili UWP源码阅读 1 - 视频播放控制 | cyf 小博客</title>
  














<meta name="generator" content="Hexo 4.2.1"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>
<a href="https://github.com/cyf-gh" target="_blank" rel="noopener" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">cyf 小博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">不会写文，文笔很差。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://cyf-my.gitee.io/2020/07/19/uwpbili-src-read-1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="cyf">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cyf 小博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">BiliBili UWP源码阅读 1 - 视频播放控制</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-07-19T17:20:40+08:00">
                2020-07-19
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/BiliBiliUWP/" itemprop="url" rel="index">
                    <span itemprop="name">BiliBiliUWP</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          <!--
          
             <span id="/2020/07/19/uwpbili-src-read-1/" class="leancloud_visitors" data-flag-title="BiliBili UWP源码阅读 1 - 视频播放控制">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数<span class="leancloud-visitors-count"></span> </span>
               
                 
             </span>
          
          -->
          
            <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="BiliBili-UWP-源码阅读-1-视频播放控制"><a href="#BiliBili-UWP-源码阅读-1-视频播放控制" class="headerlink" title="BiliBili UWP 源码阅读  1  -  视频播放控制"></a>BiliBili UWP 源码阅读  1  -  视频播放控制</h1><p>  因为需要将Vt.Client嵌入进一个稳定播放的环境，于是就开始阅读UWP版bilibili的源码。原作者代码托管：<a href="https://github.com/xiaoyaocz/biliuwp" target="_blank" rel="noopener">这里</a>。<a id="more"></a>本人从来没有写过Winform之外的任何UI框架，所以完全是从零开始学习WPF范式的UI思维，幸亏与Winform关系精密，不至于一点都看不懂。</p>
<p>  由于前几天已经搞懂了如何控制播放器，这里先成热打铁，开始讲今天的阅读任务。</p>
<h2 id="视频相关的几个Pages"><a href="#视频相关的几个Pages" class="headerlink" title="视频相关的几个Pages"></a>视频相关的几个Pages</h2><ul>
<li>PlayerPage 视频播放时控制视频的移盘表</li>
<li>VideoViewPage 视频详情页</li>
</ul>
<h2 id="打开一个视频进入播放页面"><a href="#打开一个视频进入播放页面" class="headerlink" title="打开一个视频进入播放页面"></a>打开一个视频进入播放页面</h2><p>我需要找到biliuwp是如何打开视频进入播放页面与其重要数据的，以此来实现当房主进行视频点击时客人所用的客户端都能直接打开。先定位到 <strong>VideoViewPage.xaml.cs</strong> 中，这是视频详情页Page。</p>
<p>很容易找到三个关键事件托管函数：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">btn_Play_Click</span><br><span class="line">gv_Play_ItemClick，openLastWatch_Click</span><br></pre></td></tr></table></figure>

<h3 id="行为：Navigate-方法"><a href="#行为：Navigate-方法" class="headerlink" title="行为：Navigate 方法"></a>行为：Navigate 方法</h3><p>前者可能负责的是继续播放，后者是选集播放。这两个函数都调用了一句：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(PlayerPage), new object[] &#123; ls, (gv_Play.ItemsSource as List&lt;pagesModel&gt;).IndexOf(info) &#125;);</span><br></pre></td></tr></table></figure>

<p>MessageCenter为作者自定义的静态类。</p>
<p>其定义为：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">case NavigateMode.Play:</span><br><span class="line">if (!page.FullName.Contains(&quot;MusicMiniPlayerPage&quot;))</span><br><span class="line">&#123;</span><br><span class="line">    MusicHelper.Pause();</span><br><span class="line">&#125;</span><br><span class="line">&#x2F;&#x2F;&amp;&amp;SettingHelper.IsPc()</span><br><span class="line">if (page&#x3D;&#x3D;typeof(LiveRoomPage))</span><br><span class="line">&#123;</span><br><span class="line">    PlayNavigateToEvent(typeof(LiveRoomPC), par);</span><br><span class="line">    return;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>本质是调用了PlayNavigateToEvent委托，通过全局搜索能够发现其委托的函数名叫做：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">private void MessageCenter_PlayNavigateToEvent(Type page, params object[] par)</span><br><span class="line">&#123;</span><br><span class="line">if (SettingHelper.Get_NewWindow())</span><br><span class="line">&#123;</span><br><span class="line">MessageCenter.OpenNewWindow(page, par);</span><br><span class="line">&#125;</span><br><span class="line">else</span><br><span class="line">&#123;</span><br><span class="line">play_frame.Navigate(page, par);</span><br><span class="line">&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>其中OpenNewWindow最终导向的也是Navigate函数，这是一个库函数，查询MSDN可知：</p>
<blockquote>
<h2 id="Navigate-Object-Object"><a href="#Navigate-Object-Object" class="headerlink" title="Navigate(Object, Object)"></a>Navigate(Object, Object)</h2><p>异步导航某个对象包含的内容，并传递一个对象，其中包含要在导航过程中进行处理的数据。</p>
<p>C#复制</p>
<figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">bool</span> <span class="title">Navigate</span> (<span class="params"><span class="keyword">object</span> root, <span class="keyword">object</span> navigationState</span>)</span>;</span><br></pre></td></tr></table></figure>

<h4 id="Parameters"><a href="#Parameters" class="headerlink" title="Parameters"></a>Parameters</h4><ul>
<li><p>root</p>
<p><a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.object?view=netcore-3.1" target="_blank" rel="noopener">Object</a></p>
</li>
</ul>
<p>一个包含目标导航内容的对象。</p>
<ul>
<li><p>navigationState</p>
<p><a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.object?view=netcore-3.1" target="_blank" rel="noopener">Object</a></p>
</li>
</ul>
<p>一个包含要在导航过程中进行处理的数据的对象。</p>
<h4 id="Returns"><a href="#Returns" class="headerlink" title="Returns"></a>Returns</h4><ul>
<li><a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.boolean?view=netcore-3.1" target="_blank" rel="noopener">Boolean</a></li>
</ul>
<p>如果未取消导航，则为 <code>true</code>；否则为 <code>false</code>。</p>
<h3 id="Examples"><a href="#Examples" class="headerlink" title="Examples"></a>Examples</h3><p>下面的示例演示如何导航到包含源内容并传递导航状态的 <a href="https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.controls.page?view=netcore-3.1" target="_blank" rel="noopener">Page</a> 对象。</p>
<p>C#</p>
</blockquote>
<figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">goButton_Click</span>(<span class="params"><span class="keyword">object</span> sender, RoutedEventArgs e</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">this</span>.NavigationService.Navigate(<span class="keyword">new</span> ContentPage(), DateTime.Now);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">NavigationService_LoadCompleted</span>(<span class="params"><span class="keyword">object</span> sender, NavigationEventArgs e</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    DateTime requestDateTime = (DateTime)e.ExtraData;</span><br><span class="line">    <span class="keyword">string</span> msg = <span class="keyword">string</span>.Format(<span class="string">"Request started &#123;0&#125;\nRequest completed &#123;1&#125;"</span>, requestDateTime, DateTime.Now);</span><br><span class="line">    MessageBox.Show(msg);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>则在目标Page查询NavigationEventArgs即可，找到函数：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">protected async override void OnNavigatedTo(NavigationEventArgs e)</span><br></pre></td></tr></table></figure>

<p>关键内容：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F;&#x2F; PlayerPage.xaml.cs:547</span><br><span class="line">if (e.NavigationMode &#x3D;&#x3D; NavigationMode.New)</span><br><span class="line">&#123;</span><br><span class="line">object[] obj &#x3D; e.Parameter as object[];</span><br><span class="line">var ls &#x3D; obj[0] as List&lt;PlayerModel&gt;;</span><br><span class="line">var index &#x3D; (int)obj[1];</span><br><span class="line"></span><br><span class="line">LoadPlayer(ls, index);</span><br><span class="line">sp_View.Focus(FocusState.Pointer);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>将目标数据ls与ls的某个子项目index进行读取并开始加载LoadPlayer，行为方面阅读完毕。</p>
<h3 id="数据：-ls，info，gv-play"><a href="#数据：-ls，info，gv-play" class="headerlink" title="数据： ls，info，gv_play"></a>数据： ls，info，gv_play</h3><p>gv_play与info出现于btn_Play_Click与gv_Play_ItemClick两个函数中，info为局部变量。（笔者昨天误以为VideoViewPage的所有成员函数包括aid等等为重要数据需要传输，结果发现这些数据在这两个函数中都会被最终转化为gv_play对象数组。）作者由于复用的原因将btn_play_click中的代码封装了起来，导致这两个函数在行为上不是特别的相似。</p>
<h4 id="gv-play-与-ls"><a href="#gv-play-与-ls" class="headerlink" title="gv_play 与 ls"></a>gv_play 与 ls</h4><p>  ls 数据类型为 <strong>PlayerModel</strong>，存放一些播放器启动时的元数据，gv_play 则为 <strong>pagesModel</strong>，看原型似乎是视频的一些参数。</p>
<p>  在这两个函数中，都已经将gv_play的数据转化给了ls并赋值。</p>
<h4 id="info"><a href="#info" class="headerlink" title="info"></a>info</h4><p>   在btn_Play_Click中，info一定是第一个元素：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">var info &#x3D; gv_Play.Items[0] as pagesModel;</span><br></pre></td></tr></table></figure>

<p>  而在gv_Play_ItemClick与openLastWatch_Click中，info则不一样。gv_Play_ItemClick打开的是所<strong>点击的视频</strong>：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">var info &#x3D; e.ClickedItem as pagesModel;</span><br></pre></td></tr></table></figure>

<p>而openLastWatch_Click中则会使用：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">var info &#x3D; (gv_Play.ItemsSource as List&lt;pagesModel&gt;).FirstOrDefault(x &#x3D;&gt; x.cid &#x3D;&#x3D; (long)last_view.Tag);</span><br></pre></td></tr></table></figure>

<p>上一次打开的视频位置。</p>
<h2 id="退出视频"><a href="#退出视频" class="headerlink" title="退出视频"></a>退出视频</h2><p>这个就非常简单了，再PlayerPage.xaml.cs中搜索有关的代码即可，得知退出的代码为：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">this.Frame.GoBack();</span><br></pre></td></tr></table></figure>

<p><del>注：但是需要判断一下当前Content是否为视频播放页面，不然可能会产生误操作。</del></p>
<p>绑定的事件的this一定为PlayerPage的this，无需考虑页面问题。</p>
<hr>
<p>至此所有的客户端操作已经完毕，现在开始进行通信的开发。</p>

      
    </div>
    
    
    
    <!--添加版权信息-->
    <div>
        
        
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script type="text/javascript" src="http://jslibs.wuxubj.cn/sweetalert_mini/jquery-1.7.1.min.js"></script>
  <script src="http://jslibs.wuxubj.cn/sweetalert_mini/sweetalert.min.js"></script>
  <link rel="stylesheet" type="text/css" href="http://jslibs.wuxubj.cn/sweetalert_mini/sweetalert.mini.css">

  <p><span>本文标题:</span>BiliBili UWP源码阅读 1 - 视频播放控制</a></p>
  <p><span>文章作者:</span>cyf</a></p>
  <p><span>发布时间:</span>2020年07月19日 - 17:20:40</p>
  <p><span>最后更新:</span>2020年07月20日 - 00:02:57</p>
  <p><span>原始链接:</span><a href="/2020/07/19/uwpbili-src-read-1/" title="BiliBili UWP源码阅读 1 - 视频播放控制">http://cyf-my.gitee.io/2020/07/19/uwpbili-src-read-1/</a>
    <span class="copy-path"  title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="http://cyf-my.gitee.io/2020/07/19/uwpbili-src-read-1/"  aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
    clipboard.on('success', $(function(){
      $(".fa-clipboard").click(function(){
        swal({   
          title: "",   
          text: '复制成功',   
          html: false,
          timer: 500,   
          showConfirmButton: false
        });
      });
    }));  
</script>

        
    </div>
    
    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/%E6%BA%90%E7%A0%81/" rel="tag"># 源码</a>
          
            <a href="/tags/BiliBili/" rel="tag"># BiliBili</a>
          
            <a href="/tags/UWP/" rel="tag"># UWP</a>
          
            <a href="/tags/C/" rel="tag"># C#</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2020/07/08/why-iphone-default-password-is-alpine/" rel="next" title="关于iPhone默认的root密码“alpine”">
                <i class="fa fa-chevron-left"></i> 关于iPhone默认的root密码“alpine”
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="cyf" />
          <p class="site-author-name" itemprop="name">cyf</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">13</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://www.cyf-cloud.cn" target="_blank" title="cyf-cloud">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                    
                      cyf-cloud
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://se.cyf-cloud.cn:8228" target="_blank" title="cyf-mc">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                    
                      cyf-mc
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://space.bilibili.com/3087782" target="_blank" title="哔哩哔哩">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                    
                      哔哩哔哩
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://github.com/cyf-gh || github" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                    
                      GitHub
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="mailto:cyf-ms@hotmail.com || envelope" target="_blank" title="E-Mail">
                  
                    <i class="fa fa-fw fa-envelope"></i>
                  
                    
                      E-Mail
                    
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#BiliBili-UWP-源码阅读-1-视频播放控制"><span class="nav-text">BiliBili UWP 源码阅读  1  -  视频播放控制</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#视频相关的几个Pages"><span class="nav-text">视频相关的几个Pages</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#打开一个视频进入播放页面"><span class="nav-text">打开一个视频进入播放页面</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#行为：Navigate-方法"><span class="nav-text">行为：Navigate 方法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Navigate-Object-Object"><span class="nav-text">Navigate(Object, Object)</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Parameters"><span class="nav-text">Parameters</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Returns"><span class="nav-text">Returns</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Examples"><span class="nav-text">Examples</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#数据：-ls，info，gv-play"><span class="nav-text">数据： ls，info，gv_play</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#gv-play-与-ls"><span class="nav-text">gv_play 与 ls</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#info"><span class="nav-text">info</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#退出视频"><span class="nav-text">退出视频</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">cyf</span>
</div>

<!--

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io" target="_blank" rel="noopener">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" target="_blank" rel="noopener">
    NexT.Gemini
  </a>
</div>
-->
<i class="fa">千里之行，始于足下。</i>

<!--
<span id="busuanzi_container_site_uv">
  本站总访客数:<span id="busuanzi_value_site_uv"></span>&nbsp;&nbsp;| 
</span>
<span id="busuanzi_container_site_pv">
    &nbsp;本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
</div>
</div>
-->




<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>


        
      </div>
    </footer>

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  






  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("Ykhx1csKCHE3CshrgXg8jIen-gzGzoHsz", "K8bboleYujuh7TO85MSttpvX");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  

  

  

</body>
</html>

<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/clicklove.js"></script>